<nav-bar-panel></nav-bar-panel>
<div class="content container">
    <div ng-show="currentPage==='list'">
        <h3>商户列表</h3>
        <button class="btn btn-default btn-sm" ng-click="toCreateShop()">添加商户</button>
        <div class="list-group">
            <a ng-click="toShowProductsOfShop(shop)" class="list-group-item" ng-repeat="shop in shops">
                <img ng-src="{{shop.logoUrl}}" style="width: 50px; height: 50px"/>
                {{shop.name}}</a>
        </div>
        <button class="btn btn-default btn-xs">上一页</button>
        <span>第{{page}}/{{1 + parseInt((total - 1) / pageSize)}}页</span>
        <button class="btn btn-default btn-xs">下一页</button>
    </div>
    <div ng-show="currentPage==='products_of_shop'">
        <h3>商户{{currentShop.name}}的商品</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowShops()">商户列表</button>
        <button class="btn btn-default btn-sm" ng-click="toCreateProduct()">添加商品</button>
        <button class="btn btn-default btn-sm" ng-click="toEditShop(currentShop)">编辑商户信息</button>
        <button class="btn btn-default btn-sm" ng-click="toViewShopFeedbacks(currentShop)">查看投诉</button>
        <button class="btn btn-default btn-sm" ng-click="toManageShopComments(currentShop)">评论管理</button>
        <div class="list-group">
            <a ng-click="toEditProduct(product)" class="list-group-item" ng-repeat="product in productsOfCurrentShop">
                <img ng-src="{{product.logoUrl}}" style="width: 50px; height: 50px"/>
                {{product.name}}</a>
        </div>
    </div>
    <div ng-show="currentPage==='comments_of_shop'">
        <h3>商户{{currentShop.name}}的评论管理</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowProductsOfShop(currentShop)">回到商户{{currentShop.name}}</button>
        <div>
            <button class="btn btn-danger btn-sm" ng-click="deleteSelectedShopComments()">批量删除</button>
            <table class="table table-striped">
                <thead>
                <th><button class="btn btn-primary btn-xs" ng-click="selectAllCurrentShopComments()">全选</button></th>
                <th>发布人</th>
                <th>标题</th>
                <th>内容</th>
                <th>操作</th>
                </thead>
                <tbody>
                <tr ng-repeat="comment in shopComments">
                    <td><input type="checkbox" checklist-model="selectedShopComments" checklist-value="comment.id"/></td>
                    <td>{{comment.user.displayName}}</td>
                    <td>{{comment.title}}</td>
                    <td>
                        <p class="well well-sm" ng-if="comment.content.length<24 || comment.contentOpened">
                            {{comment.content}}
                            <a ng-click="comment.contentOpened=false" ng-if="comment.content.length>24">收回</a>
                        </p>
                        <p class="well well-sm" ng-if="comment.content.length>=24 && !comment.contentOpened">
                            {{comment.content.substr(0,24)}}...&nbsp;&nbsp;
                            <a ng-click="comment.contentOpened=true">查看更多</a>
                        </p>
                    </td>
                    <td>
                        <button class="btn btn-danger btn-xs" ng-click="deleteShopComment(comment)">删除</button>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="m-pager">
                <button class="glyphicon glyphicon-triangle-left"
                        ng-show="shopCommentsPage>1"
                        ng-click="showPrevShopComments()">
                </button>
                <span>第{{shopCommentsPage}}/{{shopCommentsPagesCount()}}页</span>
                <button class="glyphicon glyphicon-triangle-right"
                        ng-show="shopCommentsTotal > shopCommentsPage * shopCommentsPageSize"
                        ng-click="showNextShopComments()">
                </button>
            </div>
        </div>
    </div>
    <div ng-show="currentPage==='feedbacks'">
        <h3>商户{{currentShop.name}}的投诉</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowProductsOfShop(currentShop)">回到商户{{currentShop.name}}</button>
        <div class="list-group">
            <p class="list-group-item" ng-repeat="feedback in feedbacks">
                <span>来自用户{{feedback.name}} <span ng-if="feedback.phone">{{feedback.phone}}</span></span>
                <span>{{feedback.title}}</span>
                <p>{{feedback.content}}</p>
            </p>
        </div>
        <button class="btn btn-default btn-xs"
                ng-click="feedbacksPage = feedbacksPage - 1; loadFeedbacksOfCurrentShop()">上一页</button>
        <span>第{{feedbacksPage}}/{{1 + parseInt((feedbacksTotal - 1) / pageSize)}}页</span>
        <button class="btn btn-default btn-xs"
                ng-click="feedbacksPage = feedbacksPage + 1; loadFeedbacksOfCurrentShop()">下一页</button>
    </div>
    <div ng-show="currentPage==='edit_shop'">
        <h3>编辑商户{{currentShop.name}}</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowShops()">商户列表</button>
        <div>
            <form class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">商户名称</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="currentShop.name" class="form-control" placeholder="商户名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商户描述</label>

                    <div class="col-sm-10">
                        <ueditor ng-model="currentShop.description"></ueditor>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">联系方式</label>

                    <div class="col-sm-10">
                        <textarea ng-model="currentShop.contact"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">折扣</label>

                    <div class="col-sm-10">

                        <input type="text" ng-model="currentShop.discount" class="form-control"
                               placeholder="折扣(扣除比例，比如0.3表示7折)"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">地址</label>

                    <div class="col-sm-10">
                        <textarea ng-model="currentShop.address"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">分类</label>

                    <div class="col-sm-10">
                        <select class="form-control" ng-model="currentShop.categoryId">
                            <option value="{{category.id}}" ng-repeat="category in shopCategories">{{category.name}}
                            </option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">图标</label>

                    <div class="col-sm-10">
                        <img ng-src="{{currentShop.logoUrl}}" style="width: 50px; height: 50px"/>
                        <upload-file-panel upload-button-name="上传图标" on-uploaded="onUploadedShopAvatar" is-public="true"></upload-file-panel>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit"
                                ng-click="updateShop(currentShop)"
                                class="btn btn-default">修改
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div ng-show="currentPage==='create'">
        <h3>添加商户</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowShops()">商户列表</button>
        <div>
            <form class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">商户名称</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="newShopName" class="form-control" placeholder="商户名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商户描述</label>

                    <div class="col-sm-10">
                        <ueditor ng-model="newShopDescription"></ueditor>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">联系方式</label>

                    <div class="col-sm-10">
                        <textarea ng-model="newShopContact"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">折扣</label>

                    <div class="col-sm-10">

                        <input type="text" ng-model="newShopDiscount" class="form-control"
                               placeholder="折扣(扣除比例，比如0.3表示7折)"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">地址</label>

                    <div class="col-sm-10">
                        <textarea ng-model="newShopAddress"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">分类</label>

                    <div class="col-sm-10">
                        <select class="form-control" ng-model="newShopCategoryId">
                            <option value="{{category.id}}" ng-repeat="category in shopCategories">{{category.name}}
                            </option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">图标</label>

                    <div class="col-sm-10">
                        <img ng-src="{{newShopLogoUrl}}" style="width: 50px; height: 50px"/>
                        <upload-file-panel upload-button-name="上传图标" on-uploaded="onUploadedShopAvatar" is-public="true"></upload-file-panel>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit"
                                ng-click="createShop(newShopName, newShopDescription, newShopCategoryId, newShopLogoUrl,newShopContact,newShopAddress, newShopDiscount);newShopName='';newShopDescription='';newShopCategoryId=categoryId;newShopLogoUrl='';newShopContact='';newShopAddress='';newShopDiscount=0;"
                                class="btn btn-default">创建
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div ng-show="currentPage==='create_product'">
        <h3>添加商品</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowProductsOfShop(currentShop)">商品列表</button>
        <div>
            <form class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品名称</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="newProductName" class="form-control" placeholder="商品名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品价格</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="newProductPrice" class="form-control" placeholder="商品价格">
                    </div>
                </div>
                <div>
                    <label class="col-sm-2 control-label">商品折扣</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="newProductDiscount" class="form-control"
                               placeholder="商品折扣(扣除比例，比如0.3表示7折)"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品描述</label>

                    <div class="col-sm-10">
                        <ueditor ng-model="newProductDescription"></ueditor>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">图标</label>

                    <div class="col-sm-10">
                        <img ng-src="{{newProductLogoUrl}}" style="width: 50px; height: 50px"/>
                        <upload-file-panel upload-button-name="上传图标" on-uploaded="onUploadedProductAvatar" is-public="true"></upload-file-panel>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit"
                                ng-click="createProduct(newProductName, newProductDescription, newProductPrice, newProductDiscount, newProductLogoUrl);newProductName='';newProductDescription='';newProductPrice='';newProductLogoUrl=''"
                                class="btn btn-default">创建
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div ng-show="currentPage==='comments_of_product'">
        <h3>商品{{currentProduct.name}}的评论管理</h3>
        <button class="btn btn-default btn-sm" ng-click="toEditProduct(currentProduct)">商品信息</button>
        <div>
            <button class="btn btn-danger btn-sm" ng-click="deleteSelectedProductComments()">批量删除</button>
            <table class="table table-striped">
                <thead>
                <th><button class="btn btn-primary btn-xs" ng-click="selectAllCurrentProductComments()">全选</button></th>
                <th>发布人</th>
                <th>标题</th>
                <th>内容</th>
                <th>操作</th>
                </thead>
                <tbody>
                <tr ng-repeat="comment in productComments">
                    <td><input type="checkbox" checklist-model="selectedProductComments" checklist-value="comment.id"/></td>
                    <td>{{comment.user.displayName}}</td>
                    <td>{{comment.title}}</td>
                    <td>
                        <p class="well well-sm" ng-if="comment.content.length<24 || comment.contentOpened">
                            {{comment.content}}
                            <a ng-click="comment.contentOpened=false" ng-if="comment.content.length>24">收回</a>
                        </p>
                        <p class="well well-sm" ng-if="comment.content.length>=24 && !comment.contentOpened">
                            {{comment.content.substr(0,24)}}...&nbsp;&nbsp;
                            <a ng-click="comment.contentOpened=true">查看更多</a>
                        </p>
                    </td>
                    <td>
                        <button class="btn btn-danger btn-xs" ng-click="deleteProductComment(comment)">删除</button>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="m-pager">
                <button class="glyphicon glyphicon-triangle-left"
                        ng-show="productCommentsPage>1"
                        ng-click="showPrevProductComments()">
                </button>
                <span>第{{productCommentsPage}}/{{productCommentsPagesCount()}}页</span>
                <button class="glyphicon glyphicon-triangle-right"
                        ng-show="productCommentsTotal > productCommentsPage * productCommentsPageSize"
                        ng-click="showNextProductComments()">
                </button>
            </div>
        </div>
    </div>
    <div ng-show="currentPage==='edit_product'">
        <h3>修改商品{{currentProduct.name}}</h3>
        <button class="btn btn-default btn-sm" ng-click="toShowProductsOfShop(currentShop)">商品列表</button>
        <button class="btn btn-default btn-sm" ng-click="toManageProductComments(currentProduct)">评论管理</button>
        <div>
            <form class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品名称</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="currentProduct.name" class="form-control" placeholder="商品名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品价格</label>

                    <div class="col-sm-10">
                        <input type="text" ng-model="currentProduct.price" class="form-control" placeholder="商品价格">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品折扣</label>

                    <div class="col-sm-10">

                        <input type="text" ng-model="currentProduct.discount" class="form-control"
                               placeholder="商品折扣(扣除比例，比如0.3表示7折)"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品描述</label>

                    <div class="col-sm-10">
                        <ueditor ng-model="currentProduct.description"></ueditor>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">图标</label>

                    <div class="col-sm-10">
                        <img ng-src="{{currentProduct.logoUrl}}" style="width: 50px; height: 50px"/>
                        <upload-file-panel upload-button-name="上传图标" on-uploaded="onUploadedProductAvatar" is-public="true"></upload-file-panel>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit"
                                ng-click="updateProductInfo(currentProduct)"
                                class="btn btn-default">修改
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<footer-bar-panel></footer-bar-panel>